package com.oim.core.business.box;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.oim.core.app.AppContext;
import com.oim.core.bean.GroupHead;
import com.oim.core.bean.UserHead;
import com.oim.core.common.app.box.Box;

/**
 * @author XiaHui
 * @date 2017年6月18日 下午9:32:36
 */
public class HeadBox extends Box {
	private Map<String, UserHead> userHeadMap = new ConcurrentHashMap<String, UserHead>();
	private Map<String, GroupHead> groupHeadMap = new ConcurrentHashMap<String, GroupHead>();

	public HeadBox(AppContext appContext) {
		super(appContext);
	}

	public void setUserHeadList(List<UserHead> list) {
		if (null != list) {
			for (UserHead h : list) {
				putUserHead(h);
			}
		}
	}

	public void putUserHead(UserHead userHead) {
		userHeadMap.put(userHead.getUserId(), userHead);
	}

	public UserHead getUserHead(String userId) {
		return userHeadMap.get(userId);
	}

	public void setGroupHeadList(List<GroupHead> list) {
		if (null != list) {
			for (GroupHead h : list) {
				putGroupHead(h);
			}
		}
	}

	public void putGroupHead(GroupHead groupHead) {
		groupHeadMap.put(groupHead.getGroupId(), groupHead);
	}

	public GroupHead getGroupHead(String groupId) {
		return groupHeadMap.get(groupId);
	}

	public String getUserHeadPath(String userId) {
		UserHead h = this.getUserHead(userId);
		String path = (null != h) ? h.getAbsolutePath() : null;
		return path;
	}
	
	public String getGroupHeadPath(String groupId) {
		GroupHead h = this.getGroupHead(groupId);
		String path = (null != h) ? h.getAbsolutePath() : null;
		return path;
	}
}
